package com.liuyi.netty.im.test.modular.controller;

import com.liuyi.netty.im.test.modular.ClientPressureTest;
import com.liuyi.rapid.develop.tool.resp.Response;
import com.liuyi.rapid.develop.tool.resp.ResponseCall;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import static org.springframework.http.ResponseEntity.ok;

/**
 * @author Mr.Fmy
 * @since 2022/1/21
 */
@RestController
@RequestMapping
@Validated
public class PressureTestController {

    @PostMapping("/pressureTest/start")
    public ResponseEntity<Response<Void>> start(@Valid @RequestBody ClientPressureTest.Config config) {
        ClientPressureTest.start(config);
        return ok(ResponseCall.<Void>successMsg("开启成功").okShow());
    }

    @PostMapping("/pressureTest/stop")
    public ResponseEntity<Response<Void>> stop() {
        ClientPressureTest.stop();
        return ok(ResponseCall.<Void>successMsg("关闭成功").okShow());
    }
}
